//
//  TipView.m
//  PurchasingMeeting
//
//  Created by yanseng.lin on 1/6/14.
//  Copyright (c) 2014 YX. All rights reserved.
//

#import "TipView.h"

@implementation TipView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        
    }
    return self;
}

-(id)initWithdic:(NSDictionary *)dic
{
    UIImage *img = [[UIHelper getInstance] getBundleImage:@"tipbackimage.png"];
    self = [super initWithFrame:CGRectMake(462, 631, img.size.width, img.size.height)];
    if ([[[UIDevice currentDevice] systemVersion] floatValue]>=7.0)
    {
        self.top = 567+64;
    }
    else
    {
        self.top = 567+32;
    }
    self.left = 1100;
    if (self) {
        UIImageView *imageview = [[UIImageView alloc]initWithImage:img];
        imageview.frame = CGRectMake(0, 0, img.size.width, img.size.height);
        [self addSubview:imageview];
        // Initialization code
        UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(50, 0, 100, 30)];
        title.text = [dic objectForKey:@"title"];
        title.backgroundColor = [UIColor clearColor];
        [imageview addSubview:title];
        
        UILabel *content = [[UILabel alloc]initWithFrame:CGRectMake(50, 30, img.size.width-50, 53)];
       // content.text = [dic objectForKey:@"content"];
        NSString *str = [dic objectForKey:@"content"];
       // CGSize s = [str sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(content.width, CGFLOAT_MAX) lineBreakMode:UILineBreakModeWordWrap];
       // content.height = s.height;
        content.text = str;
        content.numberOfLines = 2;
        content.backgroundColor = [UIColor clearColor];
        
        [imageview addSubview:content];
        
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.8];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDidStopSelector:@selector(stop)];
        self.left = 462;
        [UIView commitAnimations];
    }
    return self;
}

-(void)stop
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.8];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDelay:5];
    self.left = 1100;
    [UIView commitAnimations];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
